
//碰撞体触发器跟随摄像机.
cc.Class({
    extends: cc.Component,

    properties: {
        cameraNode:{
            default: null,
            type: cc.Node
        },
        //板子的父节点.
        boardParentNode:{
            default: null,
            type: cc.Node
        },

        overNode:{
            default: null,
            type: cc.Node
        },

        gameNode:{
            default: null,
            type: cc.Node
        }
    },

    // LIFE-CYCLE CALLBACKS:

    onLoad () {
        this.boardManager = this.boardParentNode.getComponent('BoardManager');
    },

    start () {

    },

    update (dt) {
        this.node.position = this.cameraNode.position;
    },

    onCollisionEnter: function(other,self){
        if(other.tag == 2){
            this.boardManager.putBoard(other.node);
        }
        else if(other.tag == 1){
            //玩家进入了区域.
            //游戏结束.
            this.overNode.active = true;
            //停止移动.
            this.cameraNode.getComponent('CameraFollow').isFollow = false;
            this.gameNode.getComponent('Game').isAlive = false;
            other.getComponent('Player').die();
        }
        else if(other.tag == 9){
            //单独的第一块不动的板子.
            other.node.destroy();
            console.log('第一块消除');
        }
    },
});
